<?php
session_start();
require_once 'header.php';
function __autoload($className)
	{
    	require_once('class/' . $className . '.class.php');
	}
session::need_member();
if(!empty($_GET["pagesid"]))
{
	$Page_id=intval($_GET["pagesid"]);
}
else
{
	$Page_id=1;
}
$size=40;
if(empty($Page_id)||($Page_id==1))
{
	$offset=0;
}
else 
{
	$offset=($Page_id-1)*$size;
}
if(session::is_manager()==TRUE)
{
	if(isset($_GET["userid"]))
	{
		$UserID=$_GET["userid"];
		$conditionsearch= array('payment.userid=userinfo.userid',"payment.userid=$UserID");
	}
	else 
	{
		$conditionsearch= array('payment.userid=userinfo.userid');
	}
	$GetHistoryPayment=database::LimitQuery('payment,userinfo',array(
	'select' => 'paymentid,username,date,amount,reason',
	'condition' => $conditionsearch,
	'offset' => $offset,
	'size' => $size,
	'order' => 'order by paymentid desc'
	));
	$condition=array('1=1');
	$countpages=database::count('payment', $condition);
}
else
{
	$UserId=session::getuserid();
	$GetHistoryPayment=database::LimitQuery('payment',array(
	'select' => 'date,amount,reason',
	'condition' => array(
	'userid' => $UserId
	),
	'order' => 'order by paymentid desc',
	'offset' => $offset,
	'size' => $size,
	));
	$condition=array('userid' => $UserId);
	$countpages=database::count('payment', $condition);
}
$pagesnum=ceil($countpages/$size);
require_once 'html/paymenthistory.php';


?>